package org.yjc.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.Teacher;
import org.yjc.repository.TeacherRepository;

@Service
public class TeacherService {
	@Autowired
	private TeacherRepository teacherDAO;

	public Page<Teacher> findAll(Specification<Teacher> spec, Pageable pageable) {
		return teacherDAO.findAll(spec, pageable);
	}

	public Teacher findById(Integer id) {
		Optional<Teacher> optional = teacherDAO.findById(id);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}

	public void save(Teacher teacher) {
		teacherDAO.save(teacher);
	}

	public void deleteById(Integer ids1) {
		teacherDAO.deleteById(ids1);
	}
}
